<template>
  <transition name="fade">
    <div class="c-martin__dialog__contain" v-if="visiable" :width="width">
      <div class="m-dialog__mask" @click.self="close"></div>
      <div class="c-martin__dialog" :style="{marginTop: top}">
        <div class="c-dialog__header">
          <slot name="header"></slot>
          <i class="iconfont c-dialog__header__close" @click="close">&#xe751;</i>
        </div>
        <div class="c-dialog__body">
          <slot></slot>
        </div>
        <div class="c-dialog__footer">
          <slot name="footer"></slot>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: 'MartinDialog',
  props: {
    visiable: {
      type: Boolean,
      required: true,
      default: false
    },
    width: {
      type: String,
      required: false,
      default: '30%'
    },
    top: {
      type: String,
      required: false,
      default: '15vh'
    }
  },
  methods: {
    close() {
      this.$emit('update:visiable', false)
    }
  },
  watch: {
    visiable(n) {
      if (!n) this.$emit('close')
    }
  }
}
</script>
